import { _decorator, Label, tween, UIOpacity, v3 } from 'cc';
import { ComponentExt } from 'db://cocos-ext/component/ComponentExt';

const { ccclass, property } = _decorator;

@ccclass('yy.Tips')
export class YYTips extends ComponentExt {

    @property(Label)
    lbTips: Label = null;

    /**
     * @param tips 
     * @override
     */
    init(param: any) {
        if (!param) return;
        const tips: string = param.data as string || param as string;
        this.lbTips.string = tips;
    }

    start() {
        tween(this.node)
            .by(0.8, { position: v3(0, 100) }, { easing: 'sineOut' })
            .delay(2.2)
            .removeSelf()
            .start()

        tween(this.node.getComponent(UIOpacity))
            .set({ opacity: 0 })
            .to(0.8, { opacity: 255 }, { easing: 'sineOut' })
            .start();
    }

}

